package mr.ali.video.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import mr.ali.video.web.model.CollectionIndexSelection;
import mr.ali.video.web.mapper.CollectionIndexSelectionMapper;
import mr.ali.video.web.service.ICollectionIndexSelectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Mr-ali
 * @since 2025-09-08
 */
@Service
public class CollectionIndexSelectionServiceImpl extends ServiceImpl<CollectionIndexSelectionMapper, CollectionIndexSelection> implements ICollectionIndexSelectionService {

    @Resource
    private CollectionIndexSelectionMapper collectionIndexSelectionMapper;

    @Override
    public List<CollectionIndexSelection> getCollectionIndexSelection() {
        QueryWrapper<CollectionIndexSelection> queryWrapper = new QueryWrapper<>();
        return collectionIndexSelectionMapper.selectList(queryWrapper);
    }

    @Override
    public CollectionIndexSelection updateCollectionIndexSelection(CollectionIndexSelection collectionIndexSelection) {
        QueryWrapper<CollectionIndexSelection> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", collectionIndexSelection.getId());
        collectionIndexSelectionMapper.update(collectionIndexSelection, queryWrapper);
        return collectionIndexSelection;
    }
}
